# Copyright 2010-2025 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//ortools/math_opt:__subpackages__"])

cc_library(
    name = "base_solver_test",
    testonly = 1,
    srcs = ["base_solver_test.cc"],
    hdrs = ["base_solver_test.h"],
    deps = [
        "//ortools/base:gmock",
        "//ortools/base:linked_hash_map",
        "//ortools/math_opt/cpp:math_opt",
        "@com_google_absl//absl/log",
    ],
)

cc_library(
    name = "callback_tests",
    testonly = 1,
    srcs = ["callback_tests.cc"],
    hdrs = ["callback_tests.h"],
    data = [
        "//ortools/math_opt/solver_tests/testdata:23588.mps",
    ],
    deps = [
        ":base_solver_test",
        ":test_models",
        "//ortools/base",
        "//ortools/base:gmock",
        "//ortools/base:map_util",
        "//ortools/base:status_macros",
        "//ortools/gurobi:gurobi_stdout_matchers",
        "//ortools/math_opt:callback_cc_proto",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/math_opt/io:mps_converter",
        "//ortools/port:proto_utils",
        "//ortools/port:scoped_std_stream_capture",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/synchronization",
        "@com_google_absl//absl/types:span",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "status_tests",
    testonly = 1,
    srcs = ["status_tests.cc"],
    hdrs = ["status_tests.h"],
    data = [
        "//ortools/math_opt/solver_tests/testdata:23588.mps",
    ],
    deps = [
        ":test_models",
        "//ortools/base",
        "//ortools/base:gmock",
        "//ortools/base:status_macros",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/math_opt/io:mps_converter",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "lp_tests",
    testonly = 1,
    srcs = ["lp_tests.cc"],
    hdrs = ["lp_tests.h"],
    deps = [
        ":base_solver_test",
        "//ortools/base:gmock",
        "//ortools/math_opt:solution_cc_proto",
        "//ortools/math_opt/core:solver",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status:statusor",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "lp_incomplete_solve_tests",
    testonly = 1,
    srcs = ["lp_incomplete_solve_tests.cc"],
    hdrs = ["lp_incomplete_solve_tests.h"],
    deps = [
        ":test_models",
        "//ortools/base",
        "//ortools/base:gmock",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/math_opt:solution_cc_proto",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "@com_google_absl//absl/strings",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "invalid_input_tests",
    testonly = 1,
    srcs = ["invalid_input_tests.cc"],
    hdrs = ["invalid_input_tests.h"],
    deps = [
        ":base_solver_test",
        "//ortools/base:gmock",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:model_update_cc_proto",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/math_opt/core:solver",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/math_opt/storage:model_storage",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_test(
    name = "unregistered_solver_test",
    size = "small",
    srcs = ["unregistered_solver_test.cc"],
    deps = [
        "//ortools/base:gmock",
        "//ortools/base:gmock_main",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/math_opt/core:solver_interface",
        "//ortools/math_opt/solvers:gscip_solver",
    ],
)

cc_library(
    name = "mip_tests",
    testonly = 1,
    srcs = ["mip_tests.cc"],
    hdrs = ["mip_tests.h"],
    deps = [
        ":base_solver_test",
        "//ortools/base",
        "//ortools/base:gmock",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status:statusor",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "ip_model_solve_parameters_tests",
    testonly = 1,
    srcs = ["ip_model_solve_parameters_tests.cc"],
    hdrs = ["ip_model_solve_parameters_tests.h"],
    deps = [
        ":base_solver_test",
        "//ortools/base:gmock",
        "//ortools/base:status_macros",
        "//ortools/math_opt:parameters_cc_proto",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status:statusor",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "ip_multiple_solutions_tests",
    testonly = 1,
    srcs = ["ip_multiple_solutions_tests.cc"],
    hdrs = ["ip_multiple_solutions_tests.h"],
    deps = [
        "//ortools/base:gmock",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/strings",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "lp_model_solve_parameters_tests",
    testonly = 1,
    srcs = ["lp_model_solve_parameters_tests.cc"],
    hdrs = ["lp_model_solve_parameters_tests.h"],
    deps = [
        ":base_solver_test",
        ":test_models",
        "//ortools/base:gmock",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "lp_parameter_tests",
    testonly = 1,
    srcs = ["lp_parameter_tests.cc"],
    hdrs = ["lp_parameter_tests.h"],
    deps = [
        "//ortools/base:gmock",
        "//ortools/base:status_macros",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "lp_initial_basis_tests",
    testonly = 1,
    srcs = ["lp_initial_basis_tests.cc"],
    hdrs = ["lp_initial_basis_tests.h"],
    deps = [
        ":base_solver_test",
        "//ortools/base:gmock",
        "//ortools/math_opt:solution_cc_proto",
        "//ortools/math_opt/cpp:math_opt",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status:statusor",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "ip_parameter_tests",
    testonly = 1,
    srcs = ["ip_parameter_tests.cc"],
    hdrs = ["ip_parameter_tests.h"],
    data = [
        "//ortools/math_opt/solver_tests/testdata:23588.mps",
        "//ortools/math_opt/solver_tests/testdata:beavma.mps",
    ],
    deps = [
        ":test_models",
        "//ortools/base",
        "//ortools/base:gmock",
        "//ortools/base:status_macros",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/math_opt/io:mps_converter",
        "//ortools/port:proto_utils",
        "//ortools/util:testing_utils",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "multi_objective_tests",
    testonly = 1,
    srcs = ["multi_objective_tests.cc"],
    hdrs = ["multi_objective_tests.h"],
    data = [
        "//ortools/math_opt/solver_tests/testdata:23588.mps",
    ],
    deps = [
        "//ortools/base:gmock",
        "//ortools/base:status_macros",
        "//ortools/math_opt:model_cc_proto",
        "//ortools/math_opt:model_update_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/math_opt/io:mps_converter",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_absl//absl/time",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "qp_tests",
    testonly = 1,
    srcs = ["qp_tests.cc"],
    hdrs = ["qp_tests.h"],
    deps = [
        "//ortools/base",
        "//ortools/base:gmock",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "qc_tests",
    testonly = 1,
    srcs = ["qc_tests.cc"],
    hdrs = ["qc_tests.h"],
    deps = [
        "//ortools/base:gmock",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "second_order_cone_tests",
    testonly = 1,
    srcs = ["second_order_cone_tests.cc"],
    hdrs = ["second_order_cone_tests.h"],
    deps = [
        "//ortools/base:gmock",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "logical_constraint_tests",
    testonly = 1,
    srcs = ["logical_constraint_tests.cc"],
    hdrs = ["logical_constraint_tests.h"],
    deps = [
        "//ortools/base:gmock",
        "//ortools/math_opt:model_update_cc_proto",
        "//ortools/math_opt:result_cc_proto",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "test_models",
    testonly = 1,
    srcs = ["test_models.cc"],
    hdrs = ["test_models.h"],
    deps = [
        "//ortools/math_opt/cpp:math_opt",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "test_models_test",
    srcs = ["test_models_test.cc"],
    deps = [
        ":test_models",
        "//ortools/base:gmock_main",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/math_opt/solvers:glop_solver",
        "//ortools/math_opt/solvers:gscip_solver",
    ],
)

cc_library(
    name = "generic_tests",
    testonly = True,
    srcs = ["generic_tests.cc"],
    hdrs = ["generic_tests.h"],
    deps = [
        ":test_models",
        "//ortools/base:gmock",
        "//ortools/base:logging",
        "//ortools/gurobi:gurobi_stdout_matchers",
        "//ortools/math_opt/core:inverted_bounds",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:proto_utils",
        "//ortools/port:scoped_std_stream_capture",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/synchronization",
        "@com_google_absl//absl/time",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)

cc_library(
    name = "infeasible_subsystem_tests",
    testonly = 1,
    srcs = ["infeasible_subsystem_tests.cc"],
    hdrs = ["infeasible_subsystem_tests.h"],
    deps = [
        "//ortools/base:gmock",
        "//ortools/gurobi:gurobi_stdout_matchers",
        "//ortools/math_opt:infeasible_subsystem_cc_proto",
        "//ortools/math_opt/cpp:matchers",
        "//ortools/math_opt/cpp:math_opt",
        "//ortools/port:scoped_std_stream_capture",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
    # Make sure the tests are included when using --dynamic_mode=off.
    alwayslink = 1,
)
